package main

func minSubArrayLen(target int, nums []int) int {
	minLen := 1 << 31
	sum := 0
	start := 0
	end := 0
	for end < len(nums) {
		sum += nums[end]
		for sum >= target {
			l := end - start + 1
			if l < minLen {
				minLen = l
			}
			sum -= nums[start]
			start++
		}
		end++
	}
	if minLen == 1 << 31 {
		return 0
	}
	return minLen
}

func main() {
	ans := minSubArrayLen(7, []int{2,3,1,2,4,3})
	println(ans)
}
